import { from } from 'linq';

interface IBaseTable {
	[field: string]: string | number | boolean | null | undefined;
}

export default function inner_join<Left extends IBaseTable, Right extends IBaseTable, V>(left: Left[], right: Right[], left_key: keyof Left, right_key: keyof Right) {
	return from(right).join(left, (outer) => {
		return outer[right_key] as any as V;
	}, (inner) => {
		return inner[left_key] as any as V;
	}, (outer, inner) => {
		return Object.assign(outer, inner);
	}).toArray();
}
